package com.todo.member.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/2/11 15:43
 * @description
 */
@Getter
@AllArgsConstructor
public enum MemberLevelStatusEnum {
    DRAFT(1, "DRAFT", "草稿"),
    WAIT_AUDIT(2, "WAIT_AUDIT", "待审核"),
    EFFECTIVE(3, "EFFECTIVE", "生效中"),
    INVALID(4, "INVALID", "已失效"),
    FORBIDDEN(5, "FORBIDDEN", "已废弃"),
    ;

    private static Map<Integer, MemberLevelStatusEnum> typeMap = Arrays
            .stream(MemberLevelStatusEnum.values())
            .collect(Collectors.toMap(MemberLevelStatusEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static MemberLevelStatusEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
